package dao;

import org.hibernate.*;
import Entity.SucursalEntity;
import Utils.HibernateUtil;

public class SucursalDAO {
	
	private static SucursalDAO intances;
	private static SessionFactory sf;
	
	public static SucursalDAO getInstance()
	{
		if (intances == null)
		{
			sf = HibernateUtil.getSessionFactory();
			intances = new SucursalDAO();
		}
		return intances;
	}
	
	public SucursalEntity obtenerSucursal (int nroSucursal)
	{
		SucursalEntity  suc = null;
		Session session = sf.openSession();
		Query q = session.createQuery("from SucursalEntity where idSucursal = ?").setInteger(0, nroSucursal);
		suc = (SucursalEntity) q.uniqueResult();
		return suc;
	}

}
